package com.study.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.study.bean.PictureBean;
import com.study.service.impl.AddCarItemService;
import com.study.tools.MyTools;

/**
 * Servlet implementation class CarAction
 */
@WebServlet("/CarAction")
public class CarAction extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       ///session获取c_id,host_id
//		 String cidpic= request.getSession().getAttribute("c_id").toString();
//		 Integer cidpicture=new Integer(cidpic);
		 String hostpic= request.getSession().getAttribute("Host_id").toString();
		 Integer hostpicture=new Integer(hostpic);
		///////////////// 多表关联查询购物车信息
	     
		     PictureBean pic=new PictureBean();
//		     pic.setC_id(cidpicture);
		     pic.setHost_id(hostpicture);
	        List<PictureBean> message1=MyTools.getInstance(AddCarItemService.class).getscInfo(pic);	
	        String message=JSON.toJSONString( message1);
	        System.out.println("message:"+message);
	        if(message!=null&&!message.equals("")) {
	        	
	        	PrintWriter pw=response.getWriter();
	        	pw.write(message);
	        	pw.flush();
	        	pw.close();
	        }
	}

}
